package org.rain.core.querygen.token;

import java.net.URLDecoder;
import java.nio.charset.StandardCharsets;

/**
 * 分词结果封装类
 */
public class Token {
    private String key;
    private Boolean positive; // true: 使用"=", false: 使用"!="
    private String value;
    /**
     *
     * 字段类型
     */
    private Class<?> valueClass;

    public Token(String key, boolean positive, String value) {
        this.key = key;
        this.positive = positive;
        this.value = URLDecoder.decode(value, StandardCharsets.UTF_8);
    }

    public String getKey() {
        return key;
    }

    public boolean isPositive() {
        return positive;
    }

    public String getValue() {
        return value;
    }

    public void setKey(String key) {
        this.key = key;
    }

    public void setPositive(Boolean positive) {
        this.positive = positive;
    }

    public void setValue(String value) {
        this.value = value;
    }


    @Override
    public String toString() {
        return "(" + key + ", " + positive + ", " + value + ")";
    }
}